package day0318.bigdecimal;

import java.math.BigDecimal;

/**
 * @Author Stringzhua
 * @Date 2024/3/18 18:01
 * description:
 */
public class demo03 {
    public static void main(String[] args) {
        BigDecimal bd1 = new BigDecimal("123.45");
        BigDecimal bd2 = new BigDecimal("123.4500");
        BigDecimal bd3 = new BigDecimal("1234500");

        //获取小数位数有几位
        System.out.println(bd1.scale());
        System.out.println(bd2.scale());
        System.out.println(bd3.scale());
        //stripTrailingZeros()
        System.out.println(bd1.stripTrailingZeros().scale());
        System.out.println(bd2.stripTrailingZeros().scale());
        System.out.println(bd3.stripTrailingZeros().scale());
    }
}
